﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using hello.csharp.common.Enums;

namespace hello.csharp.common.Interfaces.Logics
{
    /// <summary>
    /// 账户注册逻辑
    /// </summary>
    public interface IAccountRegisterLogic : ILogic
    {
        /// <summary>
        /// 用户注册
        /// </summary>
        /// <param name="nickname">昵称</param>
        /// <param name="email">邮箱</param>
        /// <param name="mobile">手机号码</param>
        /// <param name="pwSource">密码</param>
        /// <returns>用户注册是否成功</returns>
        Task<bool> RegisterAsync(string nickname, string email, string mobile, string pwSource);

        /// <summary>
        /// 根据指定的密码和指定的密码盐值生成保存值
        /// </summary>
        /// <param name="pwSource">指定的密码</param>
        /// <param name="pepper">指定的盐值</param>
        /// <returns>用来持久化保存的值</returns>
        string CreateHash(string pwSource, string pepper);

        /// <summary>
        /// 校验Email有效性。通过发送给用户邮件，用户点击邮件链接实现，邮件链接中保存有校验串。
        /// </summary>
        /// <param name="email">用户Email</param>
        /// <param name="value">校验串</param>
        /// <returns>Email是否有效</returns>
        Task<bool> SendUsableEmailAsync(string email, string value);

        /// <summary>
        /// 校验手机号码有效性。通过发送给用户短信，用户输入短信验证码实现。
        /// </summary>
        /// <param name="mobile">用户手机号码</param>
        /// <param name="value">校验串</param>
        /// <returns>Email是否有效</returns>
        Task<bool> SendUsableMobileAsync(string mobile, string value);

        /// <summary>
        /// 指定的唯一项是否平台唯一
        /// </summary>
        /// <param name="onlyItem">唯一项</param>
        /// <param name="value">唯一项的值</param>
        /// <returns>false表示平台已有该唯一项，true反之</returns>
        Task<bool> IsOnlyAsync(OnlyItem onlyItem, string value);
    }
}

